﻿
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using Model;
using MsDAL;
using System.ComponentModel;
using Components;

namespace ServiceHelper
{
    [DataObjectAttribute]
    public partial class Bas0a10Manager : Bas0a10Base
    {
        private static Bas0a10Manager _entity;

        public static Bas0a10Manager Entity
        {
            get
            {
                if (_entity == null)
                    _entity = new Bas0a10Manager();
                return _entity;
            }
        }

        #region 个人代码
        public string SaveData(Hashtable tb, string action, string usercode)
        {
            List<SqlApp> lst = new List<SqlApp>();

            Bas0a10 model = null;
            if ("A" == action)
            {
                model = new Bas0a10();
                CommonUtil.GetInstance.CopyProperties(tb, model);

                model.Usercode = Context.GetAppByUserCode(usercode);

                //查询状态，默认为1
                Bas0a00 statusModel = Bas0a00Manager.Entity.GetModelById(1);
                if (statusModel == null) return "当前系统常量未设置，请联系管理员！";

                model.Statuscode = statusModel.Valuecode;
                model.Statusname = statusModel.Valuename;
                model.Listid = Sys0a60Manager.Entity.CreateSn("bas0a10_listid", usercode);

                lst.Add(this.Add(model));
            }
            else if ("M" == action)
            {
                model = this.GetModelById(Validation.ToString(tb["listid"]));

                if (model == null) return string.Format("物流公司代码({0})可能已经被删除，请重新操作！",
                    tb["valuecode"]);

                CommonUtil.GetInstance.CopyProperties(tb, model);

                lst.Add(this.Update(model));
            }

            return CommonManager.Entity.SaveData(lst);
        }

        #endregion
    }
}



